/*
  Copyright © 2010  Vinícius dos Santos Oliveira

      This file is part of Touché.

      Touché is free software: you can redistribute it and/or modify
      it under the terms of the GNU Lesser General Public License as published
      by the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU Lesser General Public License for more details.

      You should have received a copy of the GNU Lesser General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */

#ifndef TOUCHEELEMENT_H
#define TOUCHEELEMENT_H

#include <QUuid>
#include <QGraphicsItem>

namespace Touche
{

    class Stage;
    class StageActor;
    class ColaborativeController;

    class Element: public QObject
    {
        friend class Stage;
        friend class StageActor;
        friend class ColaborativeController;

        Q_OBJECT

    protected:
        const QUuid m_id;
        bool m_null;

    public:
        Element();
        virtual ~Element();
        virtual const QString &type() const = 0;

        virtual QString save() const = 0;
        virtual QString file();
        virtual void load(const QString &xml, const QString &file) = 0;

        bool isNull();
        QUuid id() const;

        virtual QRectF item(QGraphicsItem *parentItem) const = 0;
        virtual QVector<QString> menuOptions() const = 0;

    public slots:
        virtual void onMenuActived(const QString &option) = 0;
        virtual void onSceneReceived(QGraphicsScene *scene);
        virtual void onElementLocked(bool locked);

    signals:
        void menuUpdated(QVector<QString>);
        void lockElement(bool lock = true);
        void sceneRequest();
        void stageRequest();
        void contentsChanged();
        void itemBoundingRectChanged(QRectF);
    };
} // namespace Touche

inline Touche::Element::Element() :
        m_id(QUuid::createUuid()),
        m_null(true)
{}

inline Touche::Element::~Element()
{}

inline QString Touche::Element::file()
{
    return QString();
}

inline bool Touche::Element::isNull()
{
    return m_null;
}

inline void Touche::Element::onSceneReceived(QGraphicsScene *)
{
    return;
}

inline void Touche::Element::onElementLocked(bool)
{
    return;
}

inline QUuid Touche::Element::id() const
{
    return m_id;
}

#endif // TOUCHEELEMENT_H
